'use strict';
module.exports = app => {
  const { STRING, INTEGER } = app.Sequelize;
  const Teacher = app.model.define(
    'teacher',
    {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
        teacher_name: STRING(32),
        number: INTEGER(11),
        school_id: INTEGER(11),
        class_id: INTEGER(11),
        course_id: INTEGER(11),
        password: STRING(255),
        sex: STRING(255),
        age: INTEGER(11),
        email: STRING(255),
      phone: STRING(255),
      birthday: STRING(255),
      type: STRING(255),
    },
    {
      tableName: 'teacher',
      timestamps: true, // 启用时间戳(createdAt, updatedAt)
      updatedAt: false, // 不想要 updatedAt
      createdAt: 'created_at', // 想要  createdAt 但是希望名称叫做 created_at
    }
  );
  Teacher.associate = () => {
    const { School, Class } = app.model;
    Teacher.hasOne(School, {foreignKey: 'id', sourceKey: 'school_id'})
    Teacher.hasOne(Class, {foreignKey: 'id', sourceKey: 'class_id'})
  };
  return Teacher;
};
